import { useModel } from "umi";

const userCheckInstitutionNameNoSelf = () => {
    const { graphqlFetch } = useModel("global");

    const checkInstitutionNameNoSelf = async (variables) => {
        let res = await graphqlFetch({
            query: `query MyQuery($oiName: String!, $notEqualTo: UUID!) { a: allOrganizationInstitutions(condition: { oiName: $oiName }, filter: { oiUuid: { notEqualTo: $notEqualTo } }) { totalCount } }`,
            variables,
        });
        return res ? res.a.totalCount : null;
    };

    return { checkInstitutionNameNoSelf };
};

export default userCheckInstitutionNameNoSelf;
